package com.okq.entity;

import com.okq.entity.base.DataEntity;
import org.apache.commons.lang.StringUtils;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;

/**
 * 描述 : 通知/公告表实体类
 * 作者 : zdl
 * 日期 : 2017/6/28 9:39
 */
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "tb_notice")
public class Notice extends DataEntity implements Serializable {
    private static final long serialVersionUID = -1033617102456694609L;
    /**
     * 标题
     */
    @Column(name = "title", length = 100)
    private String title;
    /**
     * 内容
     */
    @Column(name = "content")
    private String content;
    /**
     * 是否置顶 0 否 1 是
     */
    @Column(name = "top")
    private Integer top;
    /**
     * 置顶时间
     */
    @Column(name = "topTime")
    private String topTime;
    /**
     * 发布人
     */
    @Column(name = "release", length = 40)
    private String release;
    /**
     * 发布时间
     */
    @Column(name = "releaseTime")
    private String releaseTime;
    /**
     * 是否已发布 0未发布 1已发布
     */
    @Column(name = "isRelease")
    private Integer isRelease;
    /**
     * 是否逾期 0 未逾期 1已逾期
     */
    @Column(name = "overdue")
    private Integer overdue;
    /**
     * 逾期时间
     */
    @Column(name = "overdueTime")
    private String overdueTime;

    /* ------------------ 查询条件 ------------------*/

    /**
     * 开始时间
     */
    @Transient
    private String startTime;
    /**
     * 结束时间
     */
    @Transient
    private String endTime;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Integer getTop() {
        return top;
    }

    public void setTop(Integer top) {
        this.top = top;
    }

    public String getTopTime() {
        if (StringUtils.isNotBlank(topTime)) {
            topTime = topTime.substring(0, (topTime.lastIndexOf(".")));
        }
        return topTime;
    }

    public void setTopTime(String topTime) {
        if (StringUtils.isNotBlank(topTime)) {
            topTime = topTime + ".0";
        }
        this.topTime = topTime;
    }

    public String getRelease() {
        return release;
    }

    public void setRelease(String release) {
        this.release = release;
    }

    public String getReleaseTime() {
        if (StringUtils.isNotBlank(releaseTime)) {
            releaseTime = releaseTime.substring(0, (releaseTime.lastIndexOf(".")));
        }
        return releaseTime;
    }

    public void setReleaseTime(String releaseTime) {
        if (StringUtils.isNotBlank(releaseTime)) {
            releaseTime = releaseTime + ".0";
        }
        this.releaseTime = releaseTime;
    }

    public Integer getIsRelease() {
        return isRelease;
    }

    public void setIsRelease(Integer isRelease) {
        this.isRelease = isRelease;
    }

    public Integer getOverdue() {
        return overdue;
    }

    public void setOverdue(Integer overdue) {
        this.overdue = overdue;
    }

    public String getOverdueTime() {
        if (StringUtils.isNotBlank(overdueTime)) {
            overdueTime = overdueTime.substring(0, (overdueTime.lastIndexOf(".")));
        }
        return overdueTime;
    }

    public void setOverdueTime(String overdueTime) {
        if (StringUtils.isNotBlank(overdueTime)) {
            overdueTime = overdueTime + ".0";
        }
        this.overdueTime = overdueTime;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }
}
